<?php

namespace module\manage\validate;

use app\Validate;

class User extends Validate
{
    /**
     * 验证场景.
     *
     * @var array<array<string>>
     */
    protected $scene = [
        'reset' => ['mobile', 'password', 'password_confirm', 'smscode'],
    ];
    /**
     * 验证规则.
     *
     * @var array<string>
     */
    protected $rule = [
        'mobile' => 'requireWithout:id|regex:/^1[35789]\d{9}$/i',  // 手机号
        'password'  => 'requireWithout:id',  // 密码
        'password_confirm' => 'requireWithout:id|confirm:password',  // 确认密码
        'smscode'  => 'require',  // 短信码
        'captcha'  => 'require',  // 密码
        'idcard' => 'regex:/[1-9][0-9]{16}[\dX]/i|length:18',  // 身份证号码
    ];
    /**
     * 验证字段描述
     * 
     * @var array<string>
     */
    protected $field = [
        'mobile' => '手机号',
        'password' => '密码',
        'smscode' => '短信验证码',
        'captcha' => '图像验证码',
        'password_confirm' => '确认密码',
        'idcard' => '身份证号码',
    ];
}